package com.woniuxy.lab.woniu_lab.docker;


import com.woniuxy.lab.woniu_lab.commons.Shell;

public class Network {

    private Shell shell;

    private final static String DOCKER_NETWORK = "docker network ";

    private final static String SPACE = " ";

    public Network() {
    }

    public Network(Shell shell) {
        this.shell = shell;
    }

    public static Network getNetwork(Shell shell){
        return new Network(shell);
    }

    // -------------------

    public String create(String name){
        return shell.execCommand(DOCKER_NETWORK + name);
    }

    public String ls(){
        return shell.execCommand(DOCKER_NETWORK + "ls");
    }

    public String rm(String name){
        return shell.execCommand(DOCKER_NETWORK+"rm "+name);
    }

    public String connect(String netName, String containerName){
        return shell.execCommand(DOCKER_NETWORK+"connect "+netName+SPACE+containerName);
    }

    public String disconnect(String netName, String containerName){
        return shell.execCommand(DOCKER_NETWORK+"disconnect "+netName+SPACE+containerName);
    }

    public String inspect(String netName, String containerName){
        return shell.execCommand(DOCKER_NETWORK+"inspect "+netName+SPACE+containerName);
    }

}
